package com.hyq.learn.rabbitmq.rest;

import com.hyq.learn.rabbitmq.producer.RabbitProducer;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author heyuqin
 * @date 2024/8/20 16:52
 */
@RestController
@RequestMapping("rabbit_test")
public class RabbitController {

    @Autowired
    private RabbitProducer rabbitProducer;

    @GetMapping("{test}")
    public String test(@PathVariable String test) {
        rabbitProducer.doSend(test);
        return test;
    }

    @GetMapping("{routingKey}/{test}")
    public String test(@PathVariable String routingKey, @PathVariable String test) {
        rabbitProducer.doSend(routingKey, test);
        return test;
    }

    @GetMapping("{exchange}/{routingKey}/{test}")
    public String test(@PathVariable String exchange, @PathVariable String routingKey, @PathVariable String test) {
        rabbitProducer.doSend(exchange, routingKey, test);
        return test;
    }

}
